local map = vim.api.nvim_set_keymap
local opt = { noremap = true, silent = true }

map("n", "<C-n>", ":NvimTreeToggle<CR>", opt)
map("n", "<C-m>", ":Menu<CR>", opt)
map("n", "<leader>ps", ":PackerSync<CR>", opt)
map("n", "sp", "<Plug>(ale_previous_wrap)", opt)
map("n", "sn", "<Plug>(ale_next_wrap)", opt)
map("n", "<leader>d<space>", ":ALEDetail<CR>", opt)
map("n", "<leader>co", ":copen<CR>", opt)
map("n", "<leader>cc", ":cclose<CR>", opt)
map("n", "<leader>dp", ":lua require'dap'.repl.open()<CR>", opt)
map("n", "<C-a>", "ggVG<CR>", opt)
map("n", "<leader>k", "ddkP<CR>", opt)
map("n", "<leader>j", "ddjP<CR>", opt)
map("n", "hw", ":HopWord<CR>", opt)
map("n", "hc", ":HopChar2<CR>", opt)

vim.cmd([[
  imap <silent><expr> <Tab> luasnip#expand_or_jumpable() ? '<Plug>luasnip-expand-or-jump' : '<Tab>' 
  inoremap <silent> <S-Tab> <cmd>lua require'luasnip'.jump(-1)<Cr>
  snoremap <silent> <Tab> <cmd>lua require('luasnip').jump(1)<Cr>
  snoremap <silent> <S-Tab> <cmd>lua require('luasnip').jump(-1)<Cr>
  imap <silent><expr> <C-E> luasnip#choice_active() ? '<Plug>luasnip-next-choice' : '<C-E>'
  smap <silent><expr> <C-E> luasnip#choice_active() ? '<Plug>luasnip-next-choice' : '<C-E>'
]])
